package com.shop.loan.model.view;

import com.shop.loan.model.Channel;
import com.shop.loan.proxy.StatisticsByOverduePayProxy;
import com.shop.loan.util.LoanOrderUtil;
import lombok.Getter;
import lombok.Setter;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Filter;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.Readonly;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.DateType;
import xyz.erupt.annotation.sub_field.sub_edit.Search;
import xyz.erupt.jpa.model.BaseModel;
import xyz.erupt.upms.model.EruptUser;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Date;

@Erupt(
        name = "逾期回款统计",
        filter = @Filter("StatisticsByOverduePay.id = 0"),
        power = @Power(add = false, delete = false, edit = false, viewDetails = false),
        dataProxy = StatisticsByOverduePayProxy.class
)
@Entity
@Table(name = "s_question")
@Getter
@Setter
public class StatisticsByOverduePay extends BaseModel {


//    @EruptField(
//            edit = @Edit(
//                    title = "账单到期",
//                    type = EditType.CHOICE,
//                    search = @Search,
//                    choiceType = @ChoiceType(
//                            vl = {
//                                    @VL(label = "已到期", value = "1"),
//                            }
//                    )
//            )
//    )
//    private Integer expireStatus;


    @Transient
    @EruptField(
            edit = @Edit(title = "账单到期时间",
                    readonly = @Readonly,
                    search = @Search(vague = true),
                    dateType = @DateType(type = DateType.Type.DATE_TIME))
    )
    private Date payTime;


    @Transient
    @ManyToOne
    @EruptField(
            edit = @Edit(
                    title = "渠道",
                    search = @Search(),
                    type = EditType.REFERENCE_TREE
            )
    )
    @JoinColumn(name = "channel_id")
    private Channel channel;

    @Transient
    @ManyToOne
    @EruptField(
            edit = @Edit(
                    title = "审核客服",
                    type = EditType.REFERENCE_TREE,
                    search = @Search
            )
    )
    @JoinColumn(name = "auth_service_id")
    private EruptUser authServiceUser;

    @Transient
    @ManyToOne
    @EruptField(
            edit = @Edit(
                    title = "放款客服",
                    type = EditType.REFERENCE_TREE,
                    search = @Search
            )
    )
    @JoinColumn(name = "loan_service_id")
    private EruptUser loanServiceUser;

    @Transient
    @ManyToOne
    @EruptField(
            edit = @Edit(
                    title = "售后客服",
                    type = EditType.REFERENCE_TREE,
                    search = @Search
            )
    )
    @JoinColumn(name = "after_service_id")
    private EruptUser afterServiceUser;

    @Transient
    @ManyToOne
    @EruptField(
            edit = @Edit(
                    title = "催收客服",
                    type = EditType.REFERENCE_TREE,
                    search = @Search
            )
    )
    @JoinColumn(name = "collection_service_id")
    private EruptUser collectionServiceUser;

    @Transient
    @EruptField(
            views = @View(title = "订单数量", width = LoanOrderUtil.orderListByMoneyWidth)
    )
    private Integer orderNum;

    @Transient
    @EruptField(
            views = @View(title = "已还订单数", width = LoanOrderUtil.orderListByMoneyWidth)
    )
    private Integer payOrderNum;

    @Transient
    @EruptField(
            views = @View(title = "账单金额", width = LoanOrderUtil.orderListByMoneyWidth)
    )
    private BigDecimal money;

    @Transient
    @EruptField(
            views = @View(title = "M0还款金额", width = LoanOrderUtil.orderListByMoneyWidth)
    )
    private BigDecimal moneyByM0;

    @Transient
    @EruptField(
            views = @View(title = "M0回款比例(%)", width = LoanOrderUtil.orderListByMoneyWidth)
    )
    private BigDecimal moneyRateByM0;

    @Transient
    @EruptField(
            views = @View(title = "M1还款金额", width = LoanOrderUtil.orderListByMoneyWidth)
    )
    private BigDecimal moneyByM1;

    @Transient
    @EruptField(
            views = @View(title = "M1回款比例(%)", width = LoanOrderUtil.orderListByMoneyWidth)
    )
    private BigDecimal moneyRateByM1;

}
